<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
*/

class indexController {
    function index() {
        global $config;

        require_once  ($config['base_dir'] . "/../lib/form.php");

        $config['title'] = "chike index page";
        $config['keywords'] = "chike";
        $config['description'] = "chike";

        $form = new Form('test' , '/', false, '#header');
        $touxiang = new Files('touxiang', '头像');

        $touxiang->max_file = 2;
        
        $d = new Date('rizi','日期');

        $form->add_widget(new Email('name', '用户名'))
                ->add_widget( new Password('password', '密码'))
                ->add_widget( new Url('url', '博客地址'))
                ->add_widget($touxiang)
                ->add_widget(new Textarea('jianjie', '简介'))
                ->add_widget(new Choice('xingbie', '性别', array('男' => 1, '女' =>0), false, true))
                ->add_widget($d)
                ->add_widget(new Submit('submit','','提交'));

        if ($form->is_submit()) {
            $file ='';
            if (! $form->validate()) return false;
            if (!$file = ( $form->_fields['touxiang']->process_upload())) return false;
            
            $core = core("user");
            $core->insert($_POST['name'], $_POST['password'], $file[0]['name']);
            print_r($file);

            return false;
        }
        content($form);

    }
}
?>
